var https=require("https")
var cheerio=require("cheerio")
var fs=require("fs")
https.get("https://www.sina.com.cn",function(response){
    var html=""
     response.on("data",function(data){
        // console.log(data)
        html +=data
     })
     response.on("end",function(){
        //  console.log(html)
        //  fs.writeFileSync("./sina.txt",html)
        const $ = cheerio.load(html);
        // console.log($("img"))
        // $("img").forEach(item => {
        //     console.log(item.attribs.alt,item.attribs.src)
        // });
        for (const key in $("img")) {
            var value=$("img")[key]
            console.log(value.attribs.src,value.attribs.alt)
        }
     })
})